package com.googlecode.strutson.utils

/**
 * Propmots the user for a value until it passes the validation closure
 */
abstract class ConsoleUtils {
    static String readLine(String text, Closure validate) {
        def input = null
        while (true) {
            print text

            def scanner = new Scanner(System.in)
            input = scanner.nextLine()
            if (!validate || validate(input))
                break;
        }
        return input;
    }
}